
package com.jf.cloud.user.service.impl;

import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.util.PageUtil;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.user.mapper.UserMapper;
import com.jf.cloud.user.model.UserOrg;
import com.jf.cloud.user.mapper.UserOrgMapper;
import com.jf.cloud.user.service.UserOrgService;
import com.jf.cloud.user.vo.UserOrgVO;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author zz
 * @date 2023-03-01 20:20:59
 */
@Service
public class UserOrgServiceImpl implements UserOrgService {

    @Autowired
    private UserOrgMapper userOrgMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageVO<UserOrg> page(PageDTO pageDTO) {
        return PageUtil.doPage(pageDTO, () -> userOrgMapper.list());
    }

    @Override
    public UserOrg getById(Long id) {
        return userOrgMapper.getById(id);
    }

    @Override
    public void save(UserOrg userOrg) {
        userOrgMapper.save(userOrg);
    }

    @Override
    public void update(UserOrg userOrg) {
        userOrgMapper.update(userOrg);
    }

    @Override
    public void deleteById(Long id) {
        userOrgMapper.deleteById(id);
    }

    @Override
    public Map<String,Object> countOrg() {
        Map<String,Object> map=new HashMap<>();
        map.put("orgNum",userOrgMapper.countOrg());
        map.put("orgUserNum",userMapper.countOrgUser());
        return map;
    }
}
